<!--
 * @Description:厂端车辆查询弹窗 vehicleQueryPanel
 * @Autor: 刘诗文
 * @Date: 2021-01-13 17:44:16
 * @LastEditors: 马毅
 * @LastEditTime: 2021-06-09 13:58:01
-->
<template>
  <div>
    <FormPanel ref="formPanel" :list="formList" :cols="3" :labelWidth="130" :formType="type" :isSubmitBtn="false" />

    <el-tabs v-model="activeTab">
      <el-tab-pane label="车主信息" :name="'ownerInfo'">
        <FilterTable
          ref="ownerInfo"
          columnsRef="ownerInfolsw"
          height="300"
          :isSelectColumn="false"
          :datakey="'rows'"
          :columns="ownerInfoColumns"
          :fetchapi="ownerInfoFetchapi"
          :params="ownerInfoFetchParams"
          :onColumnsChange="columns => (this.ownerInfoColumns = columns)"
          v-if="activeTab == 'ownerInfo'"
        >
        </FilterTable>
      </el-tab-pane>
      <el-tab-pane label="维修历史信息" :name="'roHistoryInfo'">
        <FilterTable
          ref="roHistoryInfo"
          columnsRef="roHistoryInfolsw"
          selectionType="single"
          height="300"
          :isSelectColumn="false"
          :columns="roHistoryInfoColumns"
          :datakey="'rows'"
          :fetchapi="roHistoryInfoFetchapi"
          :params="roHistoryInfoFetchParams"
          :isExportExcel="true"
          exportFileName="维修历史信息.xlsx"
          :onColumnsChange="columns => (this.roHistoryInfoColumns = columns)"
          v-if="activeTab == 'roHistoryInfo'"
        >
        </FilterTable>
      </el-tab-pane>
      <el-tab-pane label="联系人信息" :name="'contactsInfo'">
        <FilterTable
          ref="contactsInfo"
          columnsRef="contactsInfolsw"
          height="300"
          :isSelectColumn="false"
          :columns="contactsInfoColumns"
          :fetchapi="contactsInfoFetchapi"
          :params="contactsInfoFetchParams"
          :datakey="'rows[0].linkOwnerList'"
          :isPagination="false"
          :isExportExcel="true"
          exportFileName="联系人信息.xlsx"
          :onColumnsChange="columns => (this.contactsInfoColumns = columns)"
          v-if="activeTab == 'contactsInfo'"
        >
        </FilterTable>
      </el-tab-pane>
      <el-tab-pane label="销售订单信息" :name="'salesOrderInfo'">
        <FilterTable
          ref="salesOrderInfo"
          columnsRef="salesOrderInfolsw"
          height="300"
          :columns="salesOrderInfoColumns"
          :datakey="'records'"
          :fetchapi="retailApi"
          :params="retailParams"
          :onColumnsChange="columns => (this.salesOrderInfoColumns = columns)"
          :is-select-column="false"
          v-if="activeTab == 'salesOrderInfo'"
        >
        </FilterTable>
      </el-tab-pane>
      <el-tab-pane label="索赔历史" :name="'claimHistory'">
        <FilterTable
          ref="claimHistory"
          columnsRef="claimHistorylsw"
          height="300"
          :isSelectColumn="false"
          :datakey="'records'"
          :columns="claimHistoryColumns"
          :fetchapi="claimHistoryFetchapi"
          v-if="activeTab == 'claimHistory'"
          :params="claimHistoryFetchParams"
          :onColumnsChange="columns => (this.claimHistoryColumns = columns)"
        >
          <template slot="controls">
            <AjaxButton size="small" type="primary" icon="el-icon-download" :click="claimHistoryExportData">导出</AjaxButton>
          </template>
        </FilterTable>
      </el-tab-pane>
      <el-tab-pane label="活动参与情况" :name="'activityInfo'" v-if="false">
        <FilterTable
          ref="activityInfo"
          columnsRef="activityInfolsw"
          height="300"
          :isSelectColumn="false"
          :columns="activityInfoColumns"
          :onColumnsChange="columns => (this.activityInfoColumns = columns)"
          v-if="activeTab == 'activityInfo'"
        >
        </FilterTable>
      </el-tab-pane>
      <el-tab-pane label="救援信息" :name="'rescueInfo'">
        <FilterTable
          ref="rescueInfo"
          columnsRef="rescueInfolsw"
          :isSelectColumn="false"
          height="300"
          :datakey="'rows'"
          :columns="rescueInfoColumns"
          :fetchapi="rescueInfoFetchapi"
          :params="rescueInfoFetchParams"
          :isExportExcel="true"
          exportFileName="救援信息.xlsx"
          :onColumnsChange="columns => (this.rescueInfoColumns = columns)"
          v-if="activeTab == 'rescueInfo'"
        >
        </FilterTable>
      </el-tab-pane>
      <el-tab-pane label="投诉信息" :name="'complaintInfo'">
        <FilterTable
          ref="complaintInfo"
          columnsRef="complaintInfolsw"
          height="300"
          :isSelectColumn="false"
          :columns="complaintInfoColumns"
          :onColumnsChange="columns => (this.complaintInfoColumns = columns)"
          v-if="activeTab == 'complaintInfo'"
        >
        </FilterTable>
      </el-tab-pane>
    </el-tabs>
    <!-- 车主明细 -->
    <BaseDialog :visible.sync="ownerActions.visible" :title="ownerActions.title" width="90%" destroyOnClose :containerStyle="{ height: '100%', overflow: 'auto' }">
      <ownerDetail :type.sync="ownerActions.type" :formData="this.resData" @close="closeHandler('ownerInfo')" />
    </BaseDialog>
    <!-- OEM维修历史详情 -->
    <BaseDialog :visible.sync="roHistoryActions.visible" :title="roHistoryActions.title" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <oemOrderDetail :repairTypeDict="repairTypeDict" :sfqfDict="sfqfDict" :orderInfo="selectedOEMHistoryOrder" @close="closeHandler('roHistoryInfo')" />
    </BaseDialog>
    <!-- 救援单明细 -->
    <Drawer :visible.sync="rescueActions.visible" :title="rescueActions.title" width="90%" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <rescueOrderQueryPanel :formData="this.resData" @close="closeHandler('rescueInfo')" />
    </Drawer>
    <!-- 索赔明细 -->
    <Drawer
      :visible.sync="claimHistoryActions.visible"
      :title="claimHistoryActions.title"
      width="90%"
      destroyOnClose
      :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }"
    >
      <claimDetails :formData="this.resData" @close="closeHandler('claimHistory')" />
    </Drawer>
    <!--操作按钮-->
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDialog">关 闭</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { exportExcelFile } from '@/utils/index';
import { isFormEmpty, notifyAction, findTableItem } from '@/utils';

import { getOwnerInfo } from '@/api/customerRepair/customerInfo/ownerVehicleManagement';
import { getWxlxSelect, getSfqfSelect } from '@/api/repair/repairReception/customer';
import { getDearlerListByTranslate } from '@/api/customerRepair/vehicleOwnerManagement/vehicleChange';
import {
  getProvince,
  getCitys,
  getDistrict,
  getRegion,
  getVehicleInfo,
  queryOEMRepairHistory,
  queryClaimHistory,
  exportClaimLogByExample
} from '@/api/customerRepair/customerInfo/ownerVehicleManagement';
import { getAllUser } from '@/api/customerRepair/afterSaleVisit/resultEntry';
import { getRetailInfoForAfterSale } from '@/api/customerRepair/vehicleOwnerManagement/vehicleChange';

import { getRescueList } from '@/api/customerRepair/rescueManagement/rescueOrder';

import ownerDetail from './ownerDetail';
import claimDetails from './claimDetails';
import oemOrderDetail from '@/pages/repair/repairReception/customer/repairHistory/oemOrderDetail';
import rescueOrderQueryPanel from '@/pages/customerRepair/rescueManagement/rescueOrderQuery/rescueOrderQueryPanel';

export default {
  name: 'vehicleQueryOEM',
  components: { ownerDetail, oemOrderDetail, rescueOrderQueryPanel, claimDetails },
  mixins: [dictionary],
  props: {
    type: {
      type: String
    },
    formData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    this.selectedData = null;
    this.resData = null;
    this.repairTypeDict = []; // 维修类型字典
    this.sfqfDict = []; // 收费区分字典
    this.selectedOEMHistoryOrder = {}; // 选中查看的OEM工单
    return {
      activeTab: 'ownerInfo',
      formList: this.createFromList(),
      ownerInfoColumns: this.createTableColumnsownerInfo(),
      roHistoryInfoColumns: this.createTableColumnsroHistoryInfo(),
      contactsInfoColumns: this.createTableColumnscontactsInfo(),
      salesOrderInfoColumns: this.createTableColumnssalesOrderInfo(),
      claimHistoryColumns: this.createTableColumnsclaimHistory(),
      activityInfoColumns: this.createTableColumnsactivityInfo(),
      rescueInfoColumns: this.createTableColumnsrescueInfo(),
      complaintInfoColumns: this.createTableColumnscomplaintInfo(),

      ownerInfoFetchapi: getOwnerInfo,
      roHistoryInfoFetchapi: queryOEMRepairHistory,
      contactsInfoFetchapi: getVehicleInfo,
      claimHistoryFetchapi: queryClaimHistory,
      rescueInfoFetchapi: getRescueList,
      retailApi: getRetailInfoForAfterSale,

      ownerInfoFetchParams: { xhrAbort: true, ownerCode: '', vin: '', type: 'OEM' },
      roHistoryInfoFetchParams: { xhrAbort: true, ownerCode: '', ownerNo: '', type: 'OEM' },
      contactsInfoFetchParams: { xhrAbort: true, ownerCode: '', ownerNo: '', type: 'OEM' },
      claimHistoryFetchParams: { xhrAbort: true, ownerCode: '', ownerNo: '' },
      rescueInfoFetchParams: { xhrAbort: true, ownerCode: '', ownerNo: '', type: 'OEM' },
      retailParams: { mobile: this.formData.mobile },

      ownerActions: { visible: false, title: '', type: 'show' },
      roHistoryActions: { visible: false, title: '', type: 'show' },
      claimHistoryActions: { visible: false, title: '', type: 'show' },
      rescueActions: { visible: false, title: '', type: 'show' },

      dealerList: []
    };
  },
  mounted() {
    if (this.formData.OWNER_CODE) {
      this.ownerInfoFetchParams.ownerCode = this.formData.OWNER_CODE;
      this.ownerInfoFetchParams.vin = this.formData.vin;
      this.ownerInfoFetchParams.xhrAbort = false;

      // this.roHistoryInfoFetchParams.ownerCode = this.formData.OWNER_CODE;
      this.roHistoryInfoFetchParams.vin = this.formData.vin;
      this.roHistoryInfoFetchParams.xhrAbort = false;

      this.contactsInfoFetchParams.ownerCode = this.formData.OWNER_CODE;
      this.contactsInfoFetchParams.linkOwnerNo = this.formData.ownerNo;
      this.contactsInfoFetchParams.xhrAbort = false;

      this.claimHistoryFetchParams.ownerCode = this.formData.OWNER_CODE;
      this.claimHistoryFetchParams.vin = this.formData.vin;
      this.claimHistoryFetchParams.xhrAbort = false;

      this.rescueInfoFetchParams.ownerCode = this.formData.OWNER_CODE;
      this.rescueInfoFetchParams.vin = this.formData.vin;
      this.rescueInfoFetchParams.xhrAbort = false;
      this.retailParams.mobile = this.formData.mobile;
      this.retailParams.vin = this.formData.vin;
    }
    // 字典值查询
    this.initDictCode();
  },
  methods: {
    createFromList() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '车辆基本信息'
        },
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'vin',
          disabled: true,
          initialValue: this.formData.vin
        },
        {
          type: 'INPUT',
          label: '车系名称',
          fieldName: 'seriesName',
          disabled: true,
          initialValue: this.formData.seriesName
        },
        {
          type: 'INPUT',
          label: '车型名称',
          fieldName: 'modelName',
          disabled: true,
          initialValue: this.formData.modelName
        },
        {
          type: 'INPUT',
          label: '配置名称',
          fieldName: 'apAckAgeName',
          disabled: true,
          initialValue: this.formData.apAckAgeName
        },
        {
          type: 'INPUT',
          label: '选装名称',
          fieldName: 'optionName',
          disabled: true,
          initialValue: this.formData.optionName
        },
        {
          type: 'INPUT',
          label: '产品代码',
          fieldName: 'a1',
          disabled: true,
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '产品名称',
          fieldName: 'a2',
          disabled: true,
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '内饰色',
          fieldName: 'innerColorName',
          disabled: true,
          initialValue: this.formData.innerColorName
        },
        {
          type: 'INPUT',
          label: '外饰色',
          fieldName: 'outColorName',
          disabled: true,
          initialValue: this.formData.outColorName
        },
        {
          type: 'DATE',
          label: '生产日期',
          fieldName: 'productDate',
          format: 'yyyy-MM-dd',
          disabled: true,
          initialValue: this.formData.productDate
        },
        {
          type: 'INPUT',
          label: '发动机号',
          fieldName: 'engineNo',
          disabled: true,
          initialValue: this.formData.engineNo
        },
        {
          type: 'INPUT',
          label: '电机号1',
          fieldName: 'motorNo1',
          disabled: true,
          initialValue: this.formData.motorNo1
        },
        // {
        //   type: 'INPUT',
        //   label: '合格证号',
        //   fieldName: 'a3',
        //   disabled: true,
        //   initialValue: ''
        // },
        // {
        //   type: 'INPUT',
        //   label: '车辆状态',
        //   fieldName: 'a4',
        //   disabled: true,
        //   initialValue: ''
        // },
        // {
        //   type: 'INPUT',
        //   label: '电池状态',
        //   fieldName: 'a5',
        //   disabled: true,
        //   initialValue: ''
        // },
        {
          type: 'BREAK_SPACE',
          label: '车辆其他信息'
        },
        {
          type: 'INPUT',
          label: '销售经销商代码',
          fieldName: 'saleOwnerNo',
          disabled: true,
          initialValue: this.formData.saleOwnerNo
        },
        {
          type: 'INPUT',
          label: '销售经销商名称',
          fieldName: 'dealerName',
          disabled: true,
          initialValue: this.formData.dealerName
        },
        {
          type: 'DATE',
          label: '发运日期',
          fieldName: 'a1',
          disabled: true,
          initialValue: ''
        },
        {
          type: 'DATE',
          label: '店端入库时间',
          fieldName: 'a2',
          disabled: true,
          initialValue: ''
        },
        {
          type: 'DATE',
          label: '实销日期',
          fieldName: 'salesDate',
          disabled: true,
          initialValue: this.formData.salesDate
        },
        {
          type: 'INPUT',
          label: '车牌号',
          fieldName: 'license',
          disabled: true,
          initialValue: this.formData.license
        },
        {
          type: 'INPUT',
          label: '当前里程',
          fieldName: 'mileage',
          disabled: true,
          initialValue: this.formData.mileage
        }
      ];
    },
    // 车主信息table
    createTableColumnsownerInfo() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 70,
          render: props => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.openHandler('ownerInfo', props.row)}>
                  明细
                </el-button>
              </div>
            );
          }
        },
        {
          title: '客户类型',
          dataIndex: 'ownerProperty',
          width: 120,
          showOverflowTooltip: true,
          dictItems: this.createDictList(8011)
        },
        {
          title: '经销商代码',
          dataIndex: 'OWNER_CODE',
          showOverflowTooltip: true
        },
        {
          title: '经销商名称',
          dataIndex: 'dealerName',
          showOverflowTooltip: true,
          render: props => {
            return <span>{this.getText(props.row.OWNER_CODE)}</span>;
          }
        },
        {
          title: '车主姓名',
          dataIndex: 'ownerName',
          width: 90,
          showOverflowTooltip: true
        },
        {
          title: '客户电话',
          dataIndex: 'phone',
          showOverflowTooltip: true
        },
        {
          title: '性别',
          dataIndex: 'gender',
          width: 90,
          showOverflowTooltip: true,
          render: props => {
            return <span>{this.createDictText(props.row.gender, 8012)}</span>;
          }
        },
        {
          title: '出生日期',
          dataIndex: 'birthday',
          width: 90,
          showOverflowTooltip: true
        },
        {
          title: '证件类型',
          dataIndex: 'ctCode',
          width: 150,
          showOverflowTooltip: true,
          render: props => {
            return <div>{this.createDictText(props.row.ctCode, 8013)}</div>;
          }
        },
        {
          title: '证件号码',
          dataIndex: 'certificateNo',
          width: 130,
          showOverflowTooltip: true
        },
        {
          title: '微信号',
          dataIndex: 'a1',
          width: 130,
          showOverflowTooltip: true
        },
        {
          title: '省份',
          dataIndex: 'province',
          width: 150,
          dictItems: [],
          showOverflowTooltip: true
        },
        {
          title: '城市',
          dataIndex: 'city',
          width: 150,
          dictItems: [],
          showOverflowTooltip: true
        },
        {
          title: '区/县',
          dataIndex: 'district',
          width: 150,
          dictItems: [],
          showOverflowTooltip: true
        },
        {
          title: '居住地址',
          dataIndex: 'address',
          width: 150,
          showOverflowTooltip: true
        },
        {
          title: '邮编',
          dataIndex: 'zipCode',
          width: 90,
          showOverflowTooltip: true
        }
      ];
    },
    //维修历史信息table
    createTableColumnsroHistoryInfo() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 70,
          render: props => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.openHandler('roHistoryInfo', props.row)}>
                  明细
                </el-button>
              </div>
            );
          }
        },
        {
          title: '工单号',
          dataIndex: 'RO_NO',
          showOverflowTooltip: true
        },
        {
          title: '维修经销商代码',
          dataIndex: 'OWNER_CODE',
          dictItems: [],
          showOverflowTooltip: true
        },
        {
          title: '维修经销商名称',
          dataIndex: 'dealerName',
          dictItems: [],
          showOverflowTooltip: true
        },
        {
          title: '车牌号',
          dataIndex: 'LICENSE',
          showOverflowTooltip: true
        },
        {
          title: 'VIN',
          dataIndex: 'VIN',
          showOverflowTooltip: true
        },
        // {
        //   title: '工单类型',
        //   dataIndex: 'a0',
        //   dictItems: [],
        //   showOverflowTooltip: true
        // },
        // {
        //   title: '活动代码',
        //   dataIndex: 'a2',
        //   showOverflowTooltip: true
        // },
        // {
        //   title: '活动名称',
        //   dataIndex: 'a3',
        //   showOverflowTooltip: true
        // },
        {
          title: '维修类型',
          dataIndex: 'REPAIR_TYPE_CODE',
          dictItems: [],
          showOverflowTooltip: true
        },
        {
          title: '进厂里程',
          dataIndex: 'IN_MILEAGE',
          showOverflowTooltip: true
        },
        {
          title: '开单日期',
          dataIndex: 'RO_CREATE_DATE',
          format: 'yyyy-MM-dd',
          showOverflowTooltip: true
        },
        // {
        //   title: '维修日期',
        //   dataIndex: 'REPAIR_BEGIN_DATE',
        //   format: 'yyyy-MM-dd',
        //   showOverflowTooltip: true
        // },
        {
          title: '结算日期',
          dataIndex: 'BALANCE_TIME',
          format: 'yyyy-MM-dd',
          showOverflowTooltip: true
        },
        {
          title: '服务工程师',
          dataIndex: 'SERVICE_ADVISOR',
          showOverflowTooltip: true
        },
        {
          title: '送修人姓名',
          dataIndex: 'DELIVERER',
          showOverflowTooltip: true
        },
        {
          title: '送修人电话',
          dataIndex: 'DELIVERER_MOBILE',
          showOverflowTooltip: true
        },
        {
          title: '送修人地址',
          dataIndex: 'a8',
          showOverflowTooltip: true
        }
      ];
    },
    //联系人信息table
    createTableColumnscontactsInfo() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '联系人姓名',
          dataIndex: 'ownerName',
          showOverflowTooltip: true
        },
        {
          title: '客户性别',
          dataIndex: 'gender',
          dictItems: this.createDictList(8012),
          showOverFlowTip: true
        },
        {
          title: '联系人与车主关系',
          dataIndex: 'relationship',
          dictItems: this.createDictList(8127),
          showOverflowTooltip: true
        },
        {
          title: '联系人电话',
          dataIndex: 'phone',
          showOverflowTooltip: true
        },
        {
          title: '联系人手机',
          dataIndex: 'mobile',
          showOverflowTooltip: true
        },
        {
          title: '省份',
          dataIndex: 'province',
          showOverflowTooltip: true
        },
        {
          title: '城市',
          dataIndex: 'city',
          showOverflowTooltip: true
        },
        {
          title: '区县',
          dataIndex: 'district',
          showOverflowTooltip: true
        },
        {
          title: '地址',
          dataIndex: 'address',
          showOverflowTooltip: true
        }
      ];
    },
    //订单销售信息table
    createTableColumnssalesOrderInfo() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '经销商代码',
          dataIndex: 'a1',
          showOverflowTooltip: true
        },
        {
          title: '经销商名称',
          dataIndex: 'a2',
          showOverflowTooltip: true
        },
        {
          title: '销售单号',
          dataIndex: 'a3',
          showOverflowTooltip: true
        },
        {
          title: 'VIN',
          dataIndex: 'a4',
          showOverflowTooltip: true
        },
        {
          title: '销售日期',
          dataIndex: 'a5',
          format: 'yyyy-MM-dd',
          showOverflowTooltip: true
        },
        {
          title: '支付方式',
          dataIndex: 'a6',
          showOverflowTooltip: true
        },
        {
          title: '发票号',
          dataIndex: 'a7',
          showOverflowTooltip: true
        },
        {
          title: '开票日期',
          dataIndex: 'a8',
          format: 'yyyy-MM-dd',
          showOverflowTooltip: true
        },
        {
          title: '是否三包',
          dataIndex: 'a9',
          showOverflowTooltip: true
        },
        {
          title: '车辆用途',
          dataIndex: 'a10',
          showOverflowTooltip: true
        }
      ];
    },
    //索赔历史table
    createTableColumnsclaimHistory() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 70,
          render: props => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.openHandler('claimHistory', props.row)}>
                  明细
                </el-button>
              </div>
            );
          }
        },
        {
          title: '索赔单号',
          dataIndex: 'claimNo',
          showOverflowTooltip: true
        },
        {
          title: '工单号',
          dataIndex: 'roNo',
          showOverflowTooltip: true
        },
        {
          title: '维修经销商代码',
          dataIndex: 'ownerCode',
          showOverflowTooltip: true
        },
        {
          title: '维修经销商名称',
          dataIndex: 'ownerName',
          showOverflowTooltip: true
        },
        {
          title: '维修类型',
          dataIndex: 'cmsClaimTypeStr',
          showOverflowTooltip: true
        },
        {
          title: '质量报告号',
          dataIndex: 'reportNo',
          showOverflowTooltip: true
        },
        {
          title: '索赔审核日期',
          dataIndex: 'checkAt',
          dateFormat: 'yyyy-MM-dd',
          showOverflowTooltip: true
        }
      ];
    },
    //活动参与情况table
    createTableColumnsactivityInfo() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '工单号',
          dataIndex: 'a1',
          showOverflowTooltip: true
        },
        {
          title: '维修经销商代码',
          dataIndex: 'a2',
          showOverflowTooltip: true
        },
        {
          title: '维修经销商名称',
          dataIndex: 'a3',
          showOverflowTooltip: true
        },
        {
          title: '维修类型',
          dataIndex: 'a4',
          showOverflowTooltip: true
        },
        {
          title: '开单时间',
          dataIndex: 'a5',
          format: 'yyyy-MM-dd',
          showOverflowTooltip: true
        },
        {
          title: '完成时间',
          dataIndex: 'a6',
          format: 'yyyy-MM-dd',
          showOverflowTooltip: true
        },
        {
          title: '优惠券码',
          dataIndex: 'a7',
          showOverflowTooltip: true
        }
      ];
    },
    //救援信息table
    createTableColumnsrescueInfo() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 70,
          render: props => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.openHandler('rescueInfo', props.row)}>
                  明细
                </el-button>
              </div>
            );
          }
        },
        {
          title: '救援单工号',
          dataIndex: 'rescueNo',
          showOverflowTooltip: true
        },
        {
          title: '救援经销商代码',
          dataIndex: 'OWNER_CODE',
          showOverflowTooltip: true
        },

        {
          title: '救援经销商名称',
          dataIndex: 'dealerName',
          dictItems: [],
          showOverflowTooltip: true
        },
        {
          title: '来电人姓名',
          dataIndex: 'ownerName',
          showOverflowTooltip: true
        },
        {
          title: '来电人电话',
          dataIndex: 'ownerMobile',
          showOverflowTooltip: true
        },
        {
          title: '救援地址',
          dataIndex: 'address',
          showOverflowTooltip: true
        },
        {
          title: '服务类型',
          dataIndex: 'rescueModeThree',
          dictItems: this.createDictList(1222),
          showOverflowTooltip: true
        },
        {
          title: '救援时间',
          dataIndex: 'appointmentDate',
          format: 'yyyy-MM-dd',
          showOverflowTooltip: true
        },
        {
          title: '派单方式',
          dataIndex: 'dataSources',
          dictItems: this.createDictList(1045),
          showOverflowTooltip: true
        }
      ];
    },
    //投诉信息table
    createTableColumnscomplaintInfo() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '工单号',
          dataIndex: 'a1',
          showOverflowTooltip: true
        },
        {
          title: '投诉经销商代码',
          dataIndex: 'a2',
          showOverflowTooltip: true
        },

        {
          title: '投诉经销商名称',
          dataIndex: 'a3',
          showOverflowTooltip: true
        },

        {
          title: '车主姓名',
          dataIndex: 'a4',
          showOverflowTooltip: true
        },

        {
          title: '车主电话',
          dataIndex: 'a5',
          showOverflowTooltip: true
        },

        {
          title: '地址',
          dataIndex: 'a6',
          showOverflowTooltip: true
        },

        {
          title: '抱怨类型',
          dataIndex: 'a7',
          showOverflowTooltip: true
        },

        {
          title: '派单方式',
          dataIndex: 'a8',
          showOverflowTooltip: true
        },

        {
          title: '处理方式',
          dataIndex: 'a9',
          showOverflowTooltip: true
        },

        {
          title: '处理状态',
          dataIndex: 'a10',
          showOverflowTooltip: true
        },

        {
          title: '仲裁处理结果',
          dataIndex: 'a11',
          showOverflowTooltip: true
        }
      ];
    },
    initDictCode() {
      // 查询经销商
      this.getDearlerListByTranslate();
      // 获取省市
      this.getRegion();
      // 获取维修类型
      this.queryRepairTypeDict();
      // 获取收费区分
      this.querySfqfDict();
      // 获取全部人员
      this.getAllUser();
    },
    // 打开弹窗
    openHandler(type, val) {
      console.log(type);
      if (type === 'ownerInfo') {
        //打开车主明细弹窗
        this.ownerActions = { visible: true, title: '车主明细', type: 'show' };
        this.resData = val;
      } else if (type === 'roHistoryInfo') {
        // 打开维修历史明细弹窗
        this.roHistoryActions = { visible: true, title: '工单信息', type: 'show' };
        this.selectedOEMHistoryOrder = val;
      } else if (type === 'claimHistory') {
        // 打开索赔历史明细弹窗
        this.claimHistoryActions = { visible: true, title: '索赔信息', type: 'show' };
        this.resData = val;
      } else if (type === 'rescueInfo') {
        // 打开救援明细弹窗
        this.rescueActions = { visible: true, title: '救援单明细', type: 'show' };
        this.resData = val;
      }
    },
    // 关闭弹窗
    closeHandler(type) {
      if (type === 'ownerInfo') {
        this.ownerActions = { visible: false, title: '车主明细', type: 'show' };
      } else if (type === 'rescueInfo') {
        this.rescueActions = { visible: false, title: '救援单明细', type: 'show' };
      } else if (type === 'roHistoryInfo') {
        this.roHistoryActions = { visible: false, title: '工单明细', type: 'show' };
      }
    },
    // 查询全部经销商列表
    async getDearlerListByTranslate() {
      const res = await getDearlerListByTranslate();
      if (res.resultCode === 200) {
        if (res.errMsg) {
          notifyAction(res.errMsg, 'error');
        } else {
          let dealerList = res.data.map(item => ({ text: item.dealerName, value: item.dealerCode + '' }));
          this.dealerList = res.data;
          let targetTableItems = [findTableItem(this.roHistoryInfoColumns, 'dealerName')];
          targetTableItems.forEach(item => {
            item.dictItems = dealerList;
          });
        }
      }
    },
    // 翻译经销商列表
    getText(val) {
      return this.dealerList.find(x => x.dealerCode === val) ? this.dealerList.find(x => x.dealerCode === val).dealerName : '';
    },
    // 获取省市
    async getRegion() {
      const allRegion = await getRegion();
      let regionList = allRegion.data.map(x => ({ value: x.regionId + '', text: x.regionName }));
      let targetTableItems = [
        findTableItem(this.ownerInfoColumns, 'province'),
        findTableItem(this.ownerInfoColumns, 'city'),
        findTableItem(this.ownerInfoColumns, 'district'),
        findTableItem(this.contactsInfoColumns, 'province'),
        findTableItem(this.contactsInfoColumns, 'city'),
        findTableItem(this.contactsInfoColumns, 'district')
      ];
      targetTableItems.forEach(item => {
        item.dictItems = regionList;
      });
    },
    // 获取维修类型
    async queryRepairTypeDict() {
      let res = await getWxlxSelect();
      if (res.resultCode == 200) {
        let repairTypeDict = res.data.map(item => ({ text: item.REPAIR_TYPE_NAME, value: item.REPAIR_TYPE_CODE + '' }));
        this.repairTypeDict = repairTypeDict;
        let targetTableItems = [findTableItem(this.roHistoryInfoColumns, 'REPAIR_TYPE_CODE')];
        targetTableItems.forEach(item => {
          item.dictItems = item.filterItems = repairTypeDict;
        });
      }
    },
    // 获取收费区分(维修历史明细中需要)
    async querySfqfDict() {
      let res = await getSfqfSelect();
      if (res.resultCode == 200) {
        this.sfqfDict = res.data.map(item => ({ text: item.CHARGE_PARTITION_NAME, value: item.CHARGE_PARTITION_CODE }));
      }
    },
    // 所有用户
    async getAllUser() {
      const res = await getAllUser();
      if (res.resultCode === 200) {
        if (res.errMsg) {
          notifyAction(res.errMsg, 'error');
        } else {
          let tableList = res.data.map(x => ({ value: x.userId + '', text: x.employeeName }));
          let targetTableItems = [findTableItem(this.roHistoryInfoColumns, 'SERVICE_ADVISOR')];
          targetTableItems.forEach(item => {
            item.dictItems = tableList;
          });
        }
      }
    },
    // 索赔历史导出
    async claimHistoryExportData() {
      await exportClaimLogByExample(this.claimHistoryFetchParams).then(res => {
        if (res.status !== 'failure') {
          exportExcelFile(res.data, '索赔历史导出');
        } else {
          notifyAction('导出失败', 'error');
        }
      });
    },
    closeDialog() {
      this.$emit('close', false);
    }
  }
};
</script>
<style lang="less" scoped></style>
